home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / batch / askit11.zip / ASKIT11.DOC < prev    next >
Text File  |  1992-02-07  |  9KB  |  249 lines

  1. Program:        ASKit
  2. Package:        Part of the S3 Batch File Utility Set
  3. Version:        1.1
  4. Date:           February 7, 1992
  5. Author:         George Spafford
  6.  
  7. Purpose:
  8.  
  9. To return a DOS errorlevel that can be easily interpreted by the DOS
  10. batch language commands based on a user's keyed response.
  11.  
  12. Procedure:
  13.  
  14. ASK.EXE needs to be either in a path or in the directory (dir) with
  15. the batch menu being run.   Example:
  16.  
  17.         @echo off
  18.         cls
  19.         echo  1.   Run Lotus
  20.         echo  2.   Run dBase
  21.         echo  3.   run WordPerfect
  22.         echo .
  23.         echo  Exit to quit to DOS.
  24.         echo .
  25.         echo Please enter your choice and then press ENTER:
  26.         :REPLY
  27.         ASK
  28.         
  29.         
  30. Okay, one Line at a time:
  31.  
  32.         @echo off
  33.         
  34.         This turns the DOS echo off.  And the @symbol (DOS 4.0 & newer)
  35.         means that a user will not even see that command.  If you
  36.         exclude this, a user will see each line of your menu before it is
  37.         processed.  If you get a bad command or file name error on this
  38.         line, then your version of DOS does not support the @ symbol, 
  39.         simply omit the @ and use ECHO OFF
  40.         
  41.         cls
  42.         
  43.         This clears the screen in DOS from top to bottom.
  44.         
  45.         echo .
  46.         
  47.         This gives us a line with just a period on it.  An even better
  48.         way of getting a line that is simply a space is to type in ECHO
  49.         push the space bar and then, hold down the ALT key and press
  50.         2 5 5 on the extended numeric keypad (the number keys on the right
  51.         if you have an 101 Key keyboard).  Also, the editor you are using
  52.         must support this method of entry for extended ascii characters.
  53.         Some don't, some do.  Those that do include DOS's EDLIN and EDIT from
  54.         DOS 5.0.  If you just type in the command ECHO, it will tell you the'
  55.         status of the echo flag in DOS.
  56.         
  57.         echo 1.  Run Lotus
  58.         
  59.         This line and the two that follow it are just displaying the menu
  60.         for the user to pick from.  You can get fancier if you so desire.
  61.  
  62.         echo EXIT to quit to DOS
  63.         
  64.         Huh???? EXIT is more than one letter!?  Well, I got fed up with
  65.         the small programs that allow you to interactively work with batch
  66.         files.  I am not knocking them, but I do occasionally have the need
  67.         for multiple key stroke entry.  This answer is defined in the 
  68.         ASKTABLE.DAT file.  We will cover this in a bit.
  69.         
  70.         Echo .
  71.         
  72.         Again, this is just for spacing.
  73.         
  74.         Echo Please enter your choice and then press ENTER:
  75.         
  76.         Okay, this looks like a question but it is really just a message
  77.         for the user to enter a key.  This line by itself does nothing.
  78.         A word of caution, when you want a user to press ENTER or another
  79.         particular key, you might want to use capital letters to get their
  80.         attention.  If you use any special characters on the batch line, DOS
  81.         may interpret them as commands and signal an error.
  82.         
  83.         ASK
  84.         
  85.         Okay, here's the heart of our menu program & here is where the fun
  86.         starts.  Trust me guys, I'm a sadist.
  87.         
  88. ASK.EXE has only two command line options and neither is regularly used.
  89. ASK D will turn on debug mode and display on the screen the errorlevel of
  90. the response that you enter.  Handy if you don't have any ASCII charts around.
  91. The other command line options is the ? which brings up the help screens.
  92.  
  93. Now, if you base your menuing system around single letter entries, the program
  94. will return the decimal code of the UPPER-case version of the letter.  For
  95. example, A or a is returned as 65 and Z or z is returned as 90.  The program
  96. will do any required case-conversions automatically.
  97.  
  98. If you do not plan on having multiple letter entries, then you can skip this
  99. next section.
  100.  
  101. TABLES:
  102.  
  103. To handle multi-key inputting, ASKit relies on a previously defined table file
  104. that contains the response and the error level that should be returned when the
  105. message is entered.  This file's name is ASKTABLE.DAT and it should be in the
  106. active dir with the menu files.
  107.  
  108. Sample ASKTABLE.DAT:  (must be left justified & only have spaces between the
  109.                        response and the errorlevel).
  110.                        
  111. YES 89
  112. NO 78
  113. LOTUS 76
  114. PCS 80
  115. Quit 71
  116. P 50
  117. Q 50
  118. R 50
  119. S 130
  120.  
  121. If YES is typed then an errorlevel of 89 is returned and so forth.  The table
  122. file also allows the user the ability to remap key codes.  Say that you need
  123. to have several menu entries that in fact do the same thing.  Instead of having
  124. an errorlevel check for each entry, you can remap the keys and point them all in
  125. that direction. If you do use the table, remember that single-key entries will 
  126. still be passed by ASKit regardless of whether they are in the table or not.
  127.  
  128. I have a question for you, do you want to have spaces in your words?  If the
  129. interest exists, I can change the field delimiter from a space to the vertical
  130. pipe ("|").  This would allow multiple word answers.  As it stands now, the
  131. table response entries can not contain spaces since the space separates the
  132. entries from their respective errorlevel codes.  If you think the change is
  133. worthwhile, please let me know as it is a very easy change to make.
  134.  
  135. Using the above table, let's create a sophisticated menu: (any echo statements
  136. by themselves have the ALT 2 5 5 character following them.)
  137.  
  138. @echo off
  139. :MAINMENU
  140.      cls
  141.      echo              Bobs Menu
  142.      echo
  143.      echo  Command            Operation
  144.      echo  ----------         ----------------------------------
  145.      echo  LOTUS              Lotus 123 v2.3
  146.      echo  PCS                PC Support
  147.      echo  R                  Start PCS with minimal functions.
  148.      echo  
  149.      echo  S                  Shell to DOS
  150.      echo  Quit               Exit to DOS     
  151.      goto MAINREPLY
  152.      
  153. :MAINREPLY
  154.      ASK.EXE
  155.      If errorlevel 130 goto SHELLOUT
  156.      if errorlevel 80 goto STARTPCS
  157.      if errorlevel 76 goto STARTLOTUS
  158.      if errorlevel 71 goto FINISH
  159.      
  160. :SHELLOUT
  161.      Command.com
  162.      goto MAINMENU
  163.      
  164. :STARTPCS
  165.      call STARTPCS.BAT
  166.      goto MAINMENU
  167.      
  168. :STARTLOTUS
  169.      cd\123
  170.      lotus
  171.      cd\
  172.      goto MAINMENU
  173.      
  174. :FINISH
  175.  
  176. <<<<<< END ... DO NOT TYPE THIS >>>>
  177.  
  178. Notice that the "IF ERRORLEVEL" statements are in descending order.  This is
  179. very important if your menu is to work correctly.  Always have it in descending
  180. order.
  181.  
  182. Next, see the :NAME places at the top of each module?  This is called a "LABEL"
  183. and it is used to identify a block of code.  You can then use GOTO statements
  184. to run that LABEL. The GOTO, by the way, serves as a means for use to jump
  185. from block to block.  Notice how each block ends with GOTO MAINMENU.  This 
  186. insures that the menu will restart.
  187.  
  188.      
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. HISTORY:
  196.  
  197.    v1.1   02/06/92
  198.    
  199.           Improved the dir process a tad.  You can just put in D: or
  200.           D: and a partial file spec like c:\dos\att and D will look
  201.           for C:\DOS\ATT*.* now.  Like I said, just a few trivial
  202.           additions.
  203.           
  204.    v1.0   12/09/92
  205.    
  206.           Initial Release.          
  207.  
  208.  
  209.  
  210. Please Register Me:
  211.            
  212. This package is a little different from some utility packages that are on the
  213. market today.  If you only like one or two programs, the individual programs
  214. can be registered for $5 per concurrently used copy.  The bargain (in my
  215. eyes) is that the whole package is only $20.  It is up to you whether or not
  216. you want the entire package or only specific files.  If this package, or one
  217. of the utilities aids you, you should register your copy.  For example, say you
  218. want DCMAP & DCUPDAY, then you need only send $10.  But please, if you use this
  219. software, register it.
  220.  
  221.                 Sincerely,
  222.  
  223.                 George Spafford
  224.                 3001 LakeShore Drive, #329
  225.                 St. Joseph, MI 49085
  226.  
  227.         Data:  (616) 468-5026  Queued Access BBS 14.4Kb USR Dual HST
  228.                                FIDOnet: 1:2340/0 NEC/NC Site
  229.                                Sysop:   Tim Akright
  230.                                         600+ MB Online 
  231.  
  232. NOTE:  D IS A PART OF THE DIRECTORY CONTROL PACKAGE.  THE FOLLOWING NOTICE
  233.        PERTAINS TO IT AS WELL. 
  234.         
  235. DIRECTORY CONTROL AND ALL OF ITS COMPONENT FILES ARE DISTRIBUTED AS IS.  
  236. THE AUTHOR (GEORGE SPAFFORD) MAKES NO WARRANTY OF ANY KIND, EXPRESSED OR 
  237. IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY OR 
  238. FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THIS SOFTWARE AND 
  239. DOCUMENTATION. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DAMAGES, 
  240. INCLUDING LOST PROFITS, LOST SAVINGS, OR ANY OTHER INCIDENTAL OR 
  241. CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF OR THE INABILITY TO USE 
  242. THIS PROGRAM.
  243. -------------------------------------------------------------------------
  244.         
  245.  
  246.                                                                                        
  247.  
  248.  
  249.